/**
 * Created: 2011-7-23
 * By:		eeorange
 * About:	pku 1753 - Flip Game
 * Status:	208K 125MS 
 * Details:	permutation		168K 94MS 
 */

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

typedef unsigned int State;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
State peri[16], src;

void init(){
	memset(peri, 0, sizeof(peri));
	for(int i=0; i<16; i++){
		int x = i/4;
		int y = i%4;
		peri[i] |= 1 <<  i;
		for(int j=0; j<4; j++){
			int new_x = x+dx[j];
			int new_y = y+dy[j];
			if(new_x >= 0 && new_x < 4 && new_y >= 0 && new_y < 4)
				peri[i] |= (1 << (new_x*4) + new_y);
		}
	}
}

void read_input(){
	src = 0;
	char ch[5];
	for(int i=0; i<4; i++)
	{
		scanf("%s", ch);
		for(int j=0; j<4; j++)
			src |= (ch[j] == 'b') ? (1 << i*4+j) : 0;
	}
}

int search()
{
	int A[16];

	for(int i=0; i<16; i++)
	{
		memset(A, 0, sizeof(A));
		for(int k=0; k<i; k++) A[15-k] = 1;
		do{
			State tmp = src;
			int tot = 0;
			for(int i=0; i<16; i++) if(A[i]){ tmp ^= peri[i]; tot++; };
			if(tmp == 0 || tmp == 0xffff)
				return tot;
		}while(next_permutation(A, A+16));
	}
	return -1;
}

int main(){
	init();
	read_input();
	
	int ret = search();
	if(ret != -1)
		printf("%d\n", ret);
	else 
		printf("Impossible\n");
	
	
	return 0;
}

